package fr.lelouet.tools.regression.normalized;

import fr.lelouet.tools.regression.Result;
import fr.lelouet.tools.regression.simple.DimensionInformations;
import fr.lelouet.tools.regression.simple.SimpleSolver;

/**
 * use the linear regression to solve the formula, and then add the importance
 * to the results.<br />
 * the importance is the coefficient from the linear regression, divided by the
 * effective range of the dimension data
 */
public class NormalizingSolver extends SimpleSolver {

	@Override
	public RelativeResult solve() {
		Result res = super.solve();
		RelativeResult rr = new RelativeResult(res);
		for (String s : res.getEstimates().keySet()) {
			DimensionInformations di = dimensions.get(s);
			if (di != null && di.hasEnoughRange()) {
				rr.getRelativeWeights().put(s,
						rr.getEstimates().get(s) * (di.maxVal() - di.minVal()));
			}
		}

		return rr;
	}

}
